local skel = fk.CreateSkill {
  name = "efengqi__jizhi",
}

Fk:loadTranslationTable{
  ["efengqi__jizhi"] = "集智",
  [":efengqi__jizhi"] = "你使用锦囊牌时，你可以令一名角色摸一张牌，若不为你，其可以交给你一张牌，令你本回合不能以此法选择该角色。",

  ["#efengqi__jizhi-choose"] = "集智：你可以令一名角色摸一张牌，其可以交给你一张牌",
  ["#efengqi__jizhi-give"] = "集智：你可以交给 %src 一张牌",

  ["$efengqi__jizhi1"] = "得上通，智集心。",
  ["$efengqi__jizhi2"] = "集万千才智，致巧趣鲜用。",
}

skel:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and player == target and data.card.type == Card.TypeTrick
  end,
  on_cost = function (self, event, target, player, data)
    local targets = table.filter(player.room.alive_players, function (p)
      return not table.contains(player:getTableMark("efengqi__jizhi-turn"), p.id)
    end)
    local tos = player.room:askToChoosePlayers(player, { targets = targets, min_num = 1, max_num = 1,
    prompt = "#efengqi__jizhi-choose", skill_name = skel.name })
    if #tos > 0 then
      event:setCostData(self, { tos = tos })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    to:drawCards(1, skel.name)
    if to ~= player and not player.dead and not to:isNude() then
      local cards = room:askToCards(to, { min_num = 1, max_num = 1, cancelable = true,
      skill_name = skel.name, include_equip = true, prompt = "#efengqi__jizhi-give:"..player.id})
      if #cards > 0 then
        room:addTableMark(player, "efengqi__jizhi-turn", to.id)
        room:obtainCard(player, cards, false, fk.ReasonGive, to, skel.name)
      end
    end
  end,
})

return skel
